home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / SYS_TOOL / BBSYSINF / SYSINFO.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-07  |  4KB  |  141 lines

  1. unit sysinfo;
  2.  
  3. interface
  4.  
  5. uses
  6.    SysUtils, WinTypes, WinProcs, Classes, BBRegis;
  7.  
  8. type
  9.    TSysInfo = class(TComponent)
  10.    private
  11.       FOrganisation : string;
  12.       FOwner : string;
  13.       FCPU : string;
  14.       FOperatingSystem : string;
  15.       FWinVersion : string;
  16.       FBuild : string;
  17.       FTotalMemory : string;
  18.       FDriveC : string;
  19.       procedure SetOrganisation(Value : string);
  20.       procedure SetOwner(Value : string);
  21.       procedure SetCPU(Value : string);
  22.       procedure SetOperatingSystem(Value : string);
  23.       procedure SetWinVersion(Value : string);
  24.       procedure SetBuild(Value : string);
  25.       procedure SetTotalMemory(Value : string);
  26.       procedure SetDriveC(Value : string);
  27.    protected
  28.    public
  29.       constructor Create(AOwner:TComponent);override;
  30.       destructor Destroy;override;
  31.    published
  32.       Property Organisation : string read FOrganisation write SetOrganisation;
  33.       Property Owner : string read FOwner write SetOwner;
  34.       Property CPU : string read FCPU write SetCPU;
  35.       Property OperatingSystem : string read FOperatingSystem write SetOperatingSystem;
  36.       Property WinVersion : string read FWinVersion write SetWinVersion;
  37.       Property Build : string read FBuild write SetBuild;
  38.       Property TotalMemory : string read FTotalMemory write SetTotalMemory;
  39.       Property DriveC : string read FDriveC write SetDriveC;
  40.       Property Name;
  41.       Property Tag;
  42. end;
  43.  
  44. procedure Register;
  45.  
  46. implementation
  47.  
  48. procedure Register;
  49. begin
  50.    RegisterComponents('Samples',[TSysInfo]);
  51. end;
  52.  
  53. constructor TSysInfo.Create(AOwner:TComponent);
  54. var
  55.    RegIni : TBBRegIniFile;
  56.    SI : TSystemInfo;
  57.    OS : TOSVersionInfo;
  58.    MemStat : TMemoryStatus;
  59. begin
  60.    inherited Create(AOwner);
  61.  
  62.    RegIni := TBBRegIniFile.Create('\SOFTWARE\Microsoft\Windows', HKEY_LOCAL_MACHINE);
  63.    FOrganisation := RegIni.ReadString('CurrentVersion', 'RegisteredOrganization', 'Failure');
  64.    FOwner := RegIni.ReadString('CurrentVersion', 'RegisteredOwner', 'Failure');
  65.    RegIni.Free;
  66.  
  67.    GetSystemInfo(SI);
  68.    case Si.dwProcessorType of
  69.       386 : FCPU := 'Intel 386';
  70.       486 : FCPU := 'Intel 486';
  71.       586 : FCPU := 'Intel Pentium';
  72.    end;
  73.  
  74.    OS.dwOSVersionInfoSize := sizeof(TOSVERSIONINFO);
  75.    GetVersionEx(OS);
  76.    case OS.dwPlatformId of
  77.       VER_PLATFORM_WIN32s        : FOperatingSystem := 'Windows 3.1';
  78.       VER_PLATFORM_WIN32_WINDOWS : FOperatingSystem := 'Windows 95';
  79.       VER_PLATFORM_WIN32_NT     : FOperatingSystem := 'Windows NT';
  80.    end;
  81.  
  82.    FWinVersion := format ('%d.%d', [OS.dwMajorVersion,OS.dwMinorVersion]);
  83.    FBuild := format('%d', [LOWORD(OS.dwBuildNumber)]);
  84.  
  85.    MemStat.dwLength := sizeof(TMemoryStatus);
  86.    GlobalMemoryStatus(MemStat);
  87.    FTotalMemory := format('%d KB',[Trunc(MemStat.dwTotalPhys/1024)]);
  88.  
  89.    if DiskSize(3) <> -1 then
  90.       FDriveC := format('%d MB', [Trunc(DiskSize(3)/1024/1024)])
  91.    else
  92.       FDriveC := '';
  93. end;
  94.  
  95. destructor TSysInfo.Destroy;
  96. begin
  97.    inherited Destroy;
  98. end;
  99.  
  100. procedure TSysInfo.SetOrganisation(Value : string);
  101. begin
  102.    FOrganisation := FOrganisation;
  103. end;
  104.  
  105. procedure TSysInfo.SetOwner(Value : string);
  106. begin
  107.    FOwner := FOwner;
  108. end;
  109.  
  110. procedure TSysInfo.SetCPU(Value : string);
  111. begin
  112.    FCPU := FCPU;
  113. end;
  114.  
  115. procedure TSysInfo.SetOperatingSystem(Value : string);
  116. begin
  117.    FOperatingSystem := FOperatingSystem;
  118. end;
  119.  
  120. procedure TSysInfo.SetWinVersion(Value : string);
  121. begin
  122.    FWinVersion := FWinVersion;
  123. end;
  124.  
  125. procedure TSysInfo.SetBuild(Value : string);
  126. begin
  127.    FBuild := FBuild;
  128. end;
  129.  
  130. procedure TSysInfo.SetTotalMemory(Value : string);
  131. begin
  132.    FTotalMemory := FTotalmemory;
  133. end;
  134.  
  135. procedure TSysInfo.SetDriveC(Value : string);
  136. begin
  137.    FDriveC := FDriveC;
  138. end;
  139.  
  140. end.
  141.